package com.diligent.cloud.sfc.resources;

import com.canny.commons.model.ObjectResult;
import com.canny.commons.model.Result;
import com.diligent.cloud.sfc.model.enums.StopReason;
import com.diligent.cloud.sfc.model.params.MatListParams;
import com.diligent.cloud.sfc.model.params.WoOrderCompleteParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

import java.security.Principal;

/**
 * WorkshopSceneResource interface
 * 车间现场资源
 * @author xf107278
 * @date 3/27/2020
 */
@RequestMapping("/sfc")
public interface WorkshopSceneResource  {

    /**
     * 紧急停机登记
     * @param stopReason 停机原因代码
     * @param remark 备注
     * @param machCode 机台代码
     * @param principal token
     * @return
     */
    @GetMapping("/mfg-mach-stop")
    @ApiOperation(value = "车间现场/紧急停机登记", notes = "车间现场/紧急停机登记",tags = {"车间现场"})
    ResponseEntity<Result> machStop(@RequestParam("stopReason") StopReason stopReason,
                                             @RequestParam("remark") String remark ,
                                             @RequestParam("machCode")String machCode,
                                             @AuthenticationPrincipal Principal principal);

    @GetMapping("/mfg-mach-stop-code")
    @ApiOperation(value = "车间现场/紧急停机登记代码", notes = "车间现场/紧急停机登记代码",tags = {"车间现场"})
    ResponseEntity<Result> getMachStopCode();

    /**
     * 更换物料
     * @param principal matCode 物料代码
     * @param principal token
     * @param principal matName 物料名字
     * @param principal machCode 机台
     * @return
     */
    @GetMapping("/mat-update")
    @ApiOperation(value = "车间现场/更换物料", notes = "车间现场/更换物料",tags = {"车间现场"})
    ResponseEntity<ObjectResult> updateMat(@RequestParam("matCode") String matCode,@RequestParam("matName") String matName,@RequestParam("machCode") String machCode, @AuthenticationPrincipal Principal principal);

    @PostMapping("/mfg-md")
    @ApiOperation(value = "车间现场/摸具加温", notes = "车间现场/摸具加温",tags = {"车间现场"})
    ResponseEntity<Result> modifyMdStatus(@ApiParam(name = "matCode", value = "模具实体", type = "String") @RequestParam("matCode") String matCode, @AuthenticationPrincipal Principal principal);

    @PostMapping("/mfg-as")
    @ApiOperation(value = "车间现场/铝棒上架", notes = "车间现场/铝棒上架",tags = {"车间现场"})
    ResponseEntity<Result> modifyAaStatus(@ApiParam(name = "asId", value = "耗材实体Id", type = "Long") @RequestParam Long asId, @AuthenticationPrincipal Principal principal);

//    @PostMapping("/mfg-mach-even")
//    @ApiOperation(value = "车间现场/发布生产异常", notes = "车间现场/发布生产异常",tags = {"车间现场"})
//    ResponseEntity<Result> insertMfgMachEven(@AuthenticationPrincipal Principal principal);


    /****
     * 更换机台模具
     * @param principal 授权令牌
     * @param mdId  模具Id
     * @param orderId  工单Id
     * @param accessToken  soa令牌
     * @param previousModelId  上一个模具Id
     * @return
     */
    @PostMapping(value = "/mat-md-update")
    @ApiOperation(value = "车间现场/更换机台模具", notes = "车间现场/更换机台模具",tags = {"车间现场"})
    ResponseEntity<Result> updateMould(@ApiParam(name = "mdId", value = "摸具Id", type = "String") @RequestParam("mdId") Long mdId,
                                       @ApiParam(name = "orderId", value = "工单Id", type = "String") @RequestParam(
                                               "orderId") Long orderId,
                                       @ApiParam(name = "accessToken", value = "令牌", type = "String") @RequestParam(
                                               "accessToken") String accessToken,
                                       @ApiParam(name = "previousModelId", value = "上一个模具Id", type = "String") @RequestParam(
                                               "previousModelId") String previousModelId,
                                       @AuthenticationPrincipal Principal principal);

    /**
     * 更换机台铝棒
     *
     * @param asId  铝棒Id
     * @param mdId 摸具Id
     * @param orderId 工单id
     * @return
     */
    @PostMapping("/mat-as-update")
    @ApiOperation(value = "车间现场/更换机台铝棒", notes = "车间现场/更换机台铝棒", tags = "车间现场")
    ResponseEntity<Result> updateAluminumStick(@ApiParam(name = "asId", value = "铝棒id", type = "String") @RequestParam("asId") Long asId,
                                               @ApiParam(name = "mdId", value = "模具Id", type = "String") @RequestParam("mdId") Long mdId,
                                               @ApiParam(name = "orderId", value = "工单Id", type = "String") @RequestParam("orderId") Long orderId,
                                               @AuthenticationPrincipal Principal principal);


//    @PostMapping("/mfg-eam-task-apply")
//    @ApiOperation(value = "车间现场/请求设备维保", notes = "车间现场/请求设备维保", tags = "车间现场")
//    ResponseEntity<Result> getEquipmentMaintenance( @AuthenticationPrincipal Principal principal);

    /***
     * 查询机台信息
     * @param devMac
     * @return
     */
    @GetMapping("/mfg-dev-environment/{devMac}")
    @ApiOperation(value = "车间现场/维护工控设备环境变量", notes = "车间现场/维护工控设备环境变量",tags = "车间现场")
    ResponseEntity<Result> getDevEnvironmentInfo(@ApiParam(name = "devMac", value = "工控设备物理地址", type = "String") @PathVariable("devMac") String devMac,
                                       @AuthenticationPrincipal Principal principal);

//    /***
//     * 请求送模
//     * @return
//     */
//    @PostMapping("/mat-md")
//    @ApiOperation(value = "车间现场/请求送摸", notes = "车间现场/请求送摸",tags = "车间现场")
//    ResponseEntity<Result> addMatMd(@AuthenticationPrincipal Principal principal);
//
//    /***
//     * 请求送模
//     * @return
//     */
//    @PostMapping("/mat-aa")
//    @ApiOperation(value = "车间现场/请求送铝棒", notes = "车间现场/请求送铝棒",tags = "车间现场")
//    ResponseEntity<Result> addMatAa(@AuthenticationPrincipal Principal principal);

    @PostMapping(value = "/mat/filter")
    @ApiOperation(value = "车间现场/获取物料列表", notes = "车间现场/获取物料列表",tags = "车间现场")
    ResponseEntity<Result> getMatList(@RequestBody MatListParams matListParams);

    @PostMapping("/mould-release")
    @ApiOperation(value = "车间现场/卸模", notes = "车间现场/卸模",tags = "车间现场")
    ResponseEntity<Result> moldRelease(@ApiParam(name = "mdId", value = "模具Id", type = "String")@RequestParam("mdId")Long mdId ,
                                       @AuthenticationPrincipal Principal principal);

    @PostMapping("/inbox")
    @ApiOperation(value = "车间现场/挤压装框", notes = "车间现场/挤压装框",tags = "车间现场")
    ResponseEntity<Result> inbox(@RequestBody WoOrderCompleteParams orderCompleteParams, @AuthenticationPrincipal Principal principal);

    @GetMapping("/inbox/{orderId}/{prodBatch}/{machCode}/{systemId}")
    @ApiOperation(value = "车间现场/获取装框细节", notes = "车间现场/获取装框细节",tags = "车间现场")
    ResponseEntity<Result> inboxDetail(@ApiParam(name = "orderId", value = "工单id", type = "Long")@PathVariable("orderId") Long orderId,
                                        @ApiParam(name = "prodBatch", value = "生产批", type = "String")@PathVariable("prodBatch") String prodBatch,
                                       @ApiParam(name = "machCode", value = "机台编号", type = "String")@PathVariable("machCode") String machCode,
                                       @ApiParam(name = "systemId", value = "账套", type = "String")@PathVariable("systemId") Long systemId );


    @GetMapping("/mfg-user-environment/{login}")
    @ApiOperation(value = "车间现场/获取当前用户环境数据", notes = "车间现场/获取当前用户环境数据",tags = "车间现场")
    ResponseEntity<Result> getDevInfo(@ApiParam(name = "login", value = "登录", type = "Boolean")@PathVariable("login") Boolean login,@AuthenticationPrincipal Principal principal);

    @PostMapping(value = "/mfg-user-environment")
    @ApiOperation(value = "车间现场/修改设备信息", notes = "车间现场/修改设备信息",tags = "车间现场")
    ResponseEntity<Result> modifyDev(Long machId,@AuthenticationPrincipal Principal principal);

    @GetMapping(value = "/mfg-user-environment")
    @ApiOperation(value = "车间现场/根据设备名查询机台信息", notes = "车间现场/根据设备名查询机台信息",tags = "车间现场")
    ResponseEntity<Result> getDevInfo(@RequestParam("machName") String machName,@AuthenticationPrincipal Principal principal);


}
